home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
fdimg
/
oh!.2hd
/
OH!DEN_B.LZH
/
TOOLS
/
DC_VIEW
/
DCTXT.C
< prev
next >
Wrap
Text File
|
1995-03-20
|
10KB
|
408 lines
/******************************************************************************
* DCtxt.c: テキスト表示処理
******************************************************************************
*
*
*/
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <stat.h>
#include <io.h>
#include <jfctype.h>
#include <doslib.h>
#include <event.h> /* イベントマンを利用するときに必要 */
#include <sxgraph.h> /* グラフ系マネージャを利用するときに必要 */
#include <window.h> /* ウィンドウマンを利用するときに必要 */
#include <dialog.h> /* ダイアログマンを利用するときに必要 */
#include <task.h> /* タスクマンを利用するときに必要 */
#include "DC.h" /* このプログラム固有のヘッダファイル */
/******************************************************************************
* drawtxt(): テキストの描画
******************************************************************************
* 引数: ComVal *pcv 共通変数へのポインタ
* int part 0:部分書きかえ
* 1:全画面書きかえ
*/
void drawtxt(ComVal *pcv, int part)
{
int i,j,jj,k,tb,vw,drawPt,end,esc;
char buff[100];
char buff2[100];
char dmyfname[100];
char *txtPt;
int *txtNo;
int pat1,pat2;
int line_no;
int cut_no;
int cut_lno,ylen;
Rect cut_rc_src;
Rect cut_rc_dst;
LPoint ppos;
Region **curRgn;
Rect rc = { 0, 0, 588, 360};
Rect rcl = {520, 363, 554, 379};
if (pcv->loadFlag == 0)
return;
GMSetGraph(&pcv->windowPtr->graph);
GMSetClip(pcv->txtRgnHdl);
MMHdlLock(pcv->txt); /* テキストのハンドルをロック */
MMHdlLock(pcv->txtNo);
txtPt = *(pcv->txt);
txtNo = *(pcv->txtNo);
if (part != 0) {
if (pcv->scrollDir > 0) { /* テキストスクロール */
GMScroll(&rc, LONGWORD(0,-12 * pcv->scrollstep), pcv->updateRgnHdl);
end = pcv->scrollstep + 1;
drawPt = (29 - pcv->scrollstep) * 12;
line_no = pcv->ofset + 29 - pcv->scrollstep;
txtPt = txtPt + *(txtNo + line_no);
} else { /* テキスト逆スクロール */
GMScroll(&rc, LONGWORD(0, 12 * pcv->scrollstep), pcv->updateRgnHdl);
end = pcv->scrollstep + 1;
drawPt = 0;
line_no = pcv->ofset;
txtPt = txtPt + *(txtNo + pcv->ofset);
}
} else { /* 全テキスト表示 */
GMForeColor(G_BLACK);
GMFillRect(&rc);
GMForeColor(G_WHITE);
end = 30;
drawPt = 0;
line_no = pcv->ofset;
txtPt = txtPt + *(txtNo + pcv->ofset);
}
for(i=0;i<end;i++) { /* テキスト描画 */
if (pcv->Maxline < (line_no + i)) break;
j = 0;
jj = 0;
vw = 0;
pcv->pre_esc = 33;
GMMove(LONGWORD(6,drawPt + i*12));
while(1) {
if (*txtPt == 13) { /* 改行処理 */
buff[j] = 0;
txtPt++;
break;
}
if (*txtPt == 10) { /* LF処理 */
txtPt++;
continue;
}
if (*txtPt == 9) { /* TAB処理 */
if (vw == 1) {
jj = jj + j / 2;
GMMove(LONGWORD(jj * 6 + 6,drawPt + i * 12));
}
tb = 8 - (jj % 8);
buff[j] = 0;
if (j > 0)
GMDrawStrZ(buff);
GMMoveRel(LONGWORD(tb * 6,0));
j = 0;
jj = jj + tb;
txtPt++;
continue;
}
if (jj == 94){ /* 行の折り返し */
pat1 =((int)*txtPt << 8) + (int)*(txtPt+1);
if (jiszen(pat1) && (*(txtPt + 2) == 13)) {
buff[j++] = *txtPt;
txtPt++;
buff[j++] = *txtPt;
txtPt++;
txtPt++;
buff[j] = 0;
break;
}
pat2 =((int)*(txtPt-1) << 8) + (int)*txtPt;
if (jiszen(pat2) && (!jiszen(pat1))) {
buff[j] = *txtPt;
buff[j+1] = 0;
txtPt++;
if (*(txtPt+1) == 13) txtPt++;
break;
}
}
if (*txtPt == '%') { /* %コード処理 */
if (*(txtPt + 1) == 'V') { /* 倍角設定 */
vw = 1;
txtPt = txtPt + 4;
buff[j] = 0;
GMDrawStrZ(buff);
j = 0;
continue;
}
if ((*(txtPt + 1) == 'C') && (*(txtPt+2) != 'U')) { /* カットファイル */
cut_no = *(txtPt+2) - '0';
cut_lno = *(txtPt+3) - '0';
if (*(txtPt+4)==':') {
while(*txtPt++ != '.') {
}
txtPt = txtPt + 3;
} else {
txtPt = txtPt + 4;
}
if (j>0) {
buff[j] = 0;
GMDrawStrZ(buff);
j = 0;
}
GMLockBits(pcv->bitsH[cut_no]);
pcv->offgraph[cut_no].bmap = &(*pcv->bitsH[cut_no])->bmap;
cut_rc_src.d.top = cut_lno * 12;
cut_rc_src.d.right = pcv->offgraph[cut_no].rect.d.right;
if (cut_rc_src.d.top + 12 > pcv->offgraph[cut_no].rect.d.bottom) {
cut_rc_src.d.bottom = pcv->offgraph[cut_no].rect.d.bottom;
ylen = cut_rc_src.d.bottom - cut_rc_src.d.top;
} else {
cut_rc_src.d.bottom = cut_rc_src.d.top + 12;
ylen = 12;
}
cut_rc_src.d.left = 0;
ppos = GMGetLoc();
cut_rc_dst.d.top = LOWWORD(ppos);
cut_rc_dst.d.right = HIWORD(ppos) + cut_rc_src.d.right;
cut_rc_dst.d.bottom = cut_rc_dst.d.top + ylen;
cut_rc_dst.d.left = HIWORD(ppos);
GMCopy(&(*pcv->bitsH[cut_no])->bmap, pcv->windowPtr->graph.bmap,
&cut_rc_src, &cut_rc_dst,
G_PSET, NULL); /* pcv->windowPtr->update); */
GMUnlockBits(pcv->bitsH[cut_no]);
GMMoveRel(LONGWORD(cut_rc_src.d.right,0));
continue;
}
}
if (*txtPt == 24) { /* 倍角解除 */
if (vw == 1) {
esc_mode(pcv, 0);
buff[j] = 0;
GMFontKind(G_ROM16);
GMFontSize(LONGWORD(16,16));
GMMoveRel(LONGWORD(0,4));
GMDrawStrZ(buff);
GMFontKind(G_ROM12);
GMFontSize(LONGWORD(12,12));
GMMoveRel(LONGWORD(0,-4));
vw = 0;
jj = jj + j / 2;
GMMove(LONGWORD(jj * 6 + 6,drawPt + i * 12));
j = 0;
txtPt++;
continue;
}
txtPt++;
continue;
}
if (*txtPt == 27) { /* esc文字属性 */
if (*(txtPt+1) == '[') {
buff2[0] = 0;
esc = 0;
txtPt++;
txtPt++;
while(*txtPt != 'm' && *txtPt != 'C') {
buff2[esc++] = *(txtPt++);
}
if (esc != 0) {
if (*txtPt == 'C') {
buff2[esc] = 0;
esc = atoi(buff2);
GMMoveRel(LONGWORD(esc*6, 0));
txtPt++;
j = 0;
continue;
}
buff2[esc] = 0;
esc = atoi(buff2);
buff[j] = 0;
GMDrawStrZ(buff);
esc_mode(pcv, esc);
txtPt++;
j = 0;
continue;
} else {
buff[j] = 0;
GMDrawStrZ(buff);
esc_mode(pcv, 0);
txtPt++;
j = 0;
continue;
}
}
}
if (jj>=94) {
break;
}
buff[j++] = *(txtPt++);
buff[j] = 0;
jj++;
}
if (vw) {
GMFontKind(G_ROM16);
GMFontSize(LONGWORD(16,16));
GMMoveRel(LONGWORD(0,4));
}
GMDrawStrZ(buff);
if (vw) {
GMFontKind(G_ROM12);
GMFontSize(LONGWORD(12,12));
GMMoveRel(LONGWORD(0,-4));
vw = 0;
}
pcv->pre_esc = 33;
esc_mode(pcv, 33);
}
MMHdlUnlock(pcv->txtNo); /* テキストのハンドルをアンロック */
MMHdlUnlock(pcv->txt);
GMSetClip(pcv->winRgnHdl);
CMValueSet(pcv->volHdl, pcv->ofset);
if (!pcv->lineDisp) { /* 行番号表示 */
GMShadowRect(&rcl);
GMMove(LONGWORD(521,364));
sprintf(buff, "%5d", pcv->ofset + 1);
GMDrawStrZ(buff);
}
}
/******************************************************************************
* esc_mode(): テキストの描画モード変更処理
******************************************************************************
* 引数: ComVal *pcv 共通変数へのポインタ
* int esc 描画モード
*/
int esc_mode(ComVal *pcv, int esc)
{
int esc_color, pre_esc_color;
int esc_mode, pre_esc_mode;
GMSetGraph(&pcv->windowPtr->graph);
if (esc == 0)
esc = 33;
pre_esc_color = (pcv->pre_esc % 10) % 4;
pre_esc_mode = pcv->pre_esc;
esc_color = (esc % 10) % 4;
esc_mode = esc;
if (esc == 1) {
if (pre_esc_mode < 34)
esc_mode = pre_esc_mode + 4;
if (pre_esc_mode > 43)
esc_mode = pre_esc_mode - 4;
esc_color = pre_esc_color;
}
if (esc == 7) {
if (pre_esc_mode < 38)
esc_mode = pre_esc_mode + 10;
if (pre_esc_mode > 39)
esc_mode = pre_esc_mode - 10;
esc_color = pre_esc_color;
}
switch(esc_color) {
case 0: GMForeColor(G_BLACK);
break;
case 1: GMForeColor(G_BLUE);
break;
case 2: GMForeColor(G_RED);
break;
case 3: GMForeColor(G_WHITE);
break;
}
if (esc_mode < 34) {
GMFontMode(G_PSET);
GMFontFace(G_PLANE);
GMFontSize(LONGWORD(12,12));
return (esc);
}
if (esc_mode < 38) {
GMFontMode(G_PSET);
GMFontFace(G_BOLD);
GMFontSize(LONGWORD(11,12));
return (esc);
}
if (esc_mode < 44) {
GMFontMode(G_NXOR);
GMFontFace(G_PLANE);
GMFontSize(LONGWORD(12,12));
return (esc);
}
if (esc_mode < 34) {
GMFontMode(G_NXOR);
GMFontFace(G_BOLD);
GMFontSize(LONGWORD(11,12));
return (esc);
}
return(esc);
}
/******************************************************************************
* scrollTxt(): テキストのスクロール処理
******************************************************************************
* 引数: ComVal *pcv 共通変数へのポインタ
* int part 1:上スクロール
* -1:下スクロール
*/
int scrollTxt(ComVal *pcv, int dir)
{
int sclbuff;
pcv->scrollDir = dir;
if (pcv->loadFlag == 0)
return;
if (dir > 0) {
if (pcv->ofset < (pcv->Maxline - 29)) {
pcv->ofset = pcv->ofset + pcv->scrollstep;
drawtxt(pcv, 1); /* ウィンドウ内部を描画する */
return (1);
}
} else {
if (pcv->ofset > 0) {
pcv->ofset = pcv->ofset - pcv->scrollstep;
if ((pcv->ofset - pcv->scrollstep) < 0) {
sclbuff = pcv->scrollstep;
pcv->scrollstep = pcv->scrollstep + pcv->ofset;
pcv->ofset = 0;
drawtxt(pcv, 1); /* ウィンドウ内部を描画する */
pcv->scrollstep = sclbuff;
} else {
drawtxt(pcv, 1); /* ウィンドウ内部を描画する */
}
return (1);
}
}
return (0);
}
STR@ &x